package com.hy.erp.inventory.service;

import java.util.List ;

import javax.ejb.Stateless ;

import org.jboss.seam.ScopeType ;
import org.jboss.seam.annotations.Name ;
import org.jboss.seam.annotations.Scope ;

import com.hy.enterprise.architecture.foundation.ArchitectureFoundationException;
import com.hy.enterprise.framework.service.business.AbstractBusinessService;
import com.hy.erp.inventory.dao.interfaces.ICountyDao;
import com.hy.erp.inventory.pojo.County;
import com.hy.erp.inventory.pojo.interfaces.ICounty;
import com.hy.erp.inventory.service.interfaces.ICountyService;
/**
 * 
 * <ul>
 * <li>开发作者：李冰</li>
 * <li>设计日期：2010-10-13；时间：上午09:17:49</li>
 * <li>类型名称：CountyService</li>
 * <li>设计目的：</li>
 * </ul>
 * <ul>
 * <b>修订编号：</b>
 * <li>修订日期：</li>
 * <li>修订作者：</li>
 * <li>修订原因：</li>
 * <li>修订内容：</li>
 * </ul>
 */
@ Name ( "countyService" )
@ Scope ( ScopeType.STATELESS )
@ Stateless
public class CountyService extends AbstractBusinessService < ICounty > implements ICountyService
{

	@ Override
	public boolean addCounty (
								ICounty county )
	{





		if ( null == county)
		{
			return true ;
		}
		
		else
		{
			System.out
						.println ("ssssssssssssssssssssssffffffffffffffffhghhhhhhhhhhhhhhhhhhhhhh") ;


			ICountyDao countyDao =
			                       ( ICountyDao ) this
			                                          .getDao ( ICounty.class ) ;
			
			return countyDao
			                .persist ( county ) ;
		}
		
	
	
	
	
	
	}

	@ Override
	public boolean modifyCounty (
									ICounty county )
	{





		if ( ( null == county )
			     || ( null == county
			                                .getIdentifier ( ) )
			     || ( county
			                        .getIdentifier ( )
			                        .trim ( )
			                        .length ( ) == 0 ) )
			{
				return true ;
			}
			else
			{

				ICountyDao countyDao =
                    ( ICountyDao ) this
                                       .getDao ( ICounty.class ) ;

		
					
				if ( null == county )
				{
					throw new ArchitectureFoundationException  (
					                                            "修改实体数据时发生错误，所需要修改的实体在数据库中并不存在" ) ;
				}
				
				
				return (countyDao
				                  .merge ( county ) != null ) ;
			}
		
	
	
	
	
	
	
	}

	@ Override
	public Integer removeCounty (
									String [ ] countyIds )
	{






		if ( ( null == countyIds)
			     || ( countyIds.length == 0 ) )
			{
				return new Integer (
				                     0 ) ;
			}
			else
			{


				ICountyDao countyDao =
                    ( ICountyDao ) this
                                       .getDao ( ICounty.class ) ;
		

				return countyDao
				                .remove ( countyIds ) ;
			}
	
	
	
	
	
	
	}

	@ Override
	public String [ ] addCounty (
									Object [ ] county )
	{






		if ( null == county)
		{
			return null ;
		}
		
		else
		{
			ICountyDao countyDao =
			                       ( ICountyDao ) this
			                                          .getDao ( ICounty.class ) ;

			County[] countys=new County[county.length];
						for(int i=0;i<county.length;i++)
						{
							County county2=( County ) county[i];
							countys[i]=county2;
						}
						return countyDao
						                .persist ( countys ) ;
			
		
		}
		
	
	
	
	
	
	
	}

	@ Override
	public List < ICounty > getAllCounty ( )
	{
		ICountyDao countyDao =
            ( ICountyDao ) this
                               .getDao ( ICounty.class ) ;


		return countyDao
		                .find ( );
	}

	@ Override
	public String [ ] modifyCounty (
										Object [ ] county )
	{







		if ( null == county)
		{
			return null ;
		}
		
		else
		{
			ICountyDao countyDao =
			                       ( ICountyDao ) this
			                                          .getDao ( ICounty.class ) ;

			County[] countys=new County[county.length];
						for(int i=0;i<county.length;i++)
						{
							County county2=( County ) county[i];
							countys[i]=county2;
						}
						return countyDao
						                .merge  ( countys ) ;
			
		
		}
		
	
	
	
	
	
	
	
	}

	
}
